/**
 * Created by 都大爽 on 2018/1/19.
 */

export default {
  serverEndPoing: 'http://xyj.local/user/works/oss-upload-policy/220859',
  signatureExpire: 0,
  signature: null,
  getSignature (){
    var me = this
    let now = Date.parse(new Date()) / 1000
    if ( this.signatureExpire < now + 3 ) {
      $.ajax({
        beforeSend: function(request) {
            request.setRequestHeader("Authorization", 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6Ijk1ZGNhMTMyMzkxYTY' +
              '2ZGY4OWFmMGNhYjY1MDBjNjcyNDE3NDhmNjNkODY5ODViMTFkNzY2ZDdjZGM0M2Y1MGY2YmRhYWE2OWRhOTlkNDNhIn0.eyJhdWQiOiI2Iiwia' +
              'nRpIjoiOTVkY2ExMzIzOTFhNjZkZjg5YWYwY2FiNjUwMGM2NzI0MTc0OGY2M2Q4Njk4NWIxMWQ3NjZkN2NkYzQzZjUwZjZiZGFhYTY5ZGE5OWQ' +
              '0M2EiLCJpYXQiOjE1MTY1OTgwOTEsIm5iZiI6MTUxNjU5ODA5MSwiZXhwIjoxNTQ4MTM0MDkwLCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.JnDde' +
              'nwzjAM0fKF3nroyVmBUigCtYF3QsMk7eb88bYoM1Bf1cLoxtwMyHdfQfmyP5OIOV-DEKkKbHPrLIOLupSWnXBjlgBjTnqJwhttycM8lV2Kt1JV' +
              'b1AxkrHEfggjauzVZo17RlSTcLqZG1a55MD_0szKTsEkpYpLn99_xNPfWuZQw6PwDKaLoGGcgKP6JcCAQKAr3FrMYVVHO-Pp1QnLECO2IpaiWK' +
              'Nd_L2Z2Q8kTjxaR9XTOurifX0owvmT34GuLf4IQwyDkGCB8nsFJjP5yZcG9iGvtIb5SMYJ0P03Mc9ZPCSwEDJ-gE-fMgWoDvQ6KTR8-GVLG06x' +
              'WfYg-ysRSafs0205xbLPFyFnerYUdsLzC9qhRYGvVV4o-gB38X_hP6mq6uxG6ZgHam1fAJOouMp-__uf6gHJCFrdZCEBXZobzi9FmDrCqiH0OX' +
              'Cx4YVtya5Q8tFp11D43BHfRq_EaGoD4n81OY1nja9izLebx5nfURTdq2FlmPMOFt5aBFJ-RKlC3O9mQI2ixO8qQGKqGMukIS3lA74dHX6BkX4f' +
              'ksMW6kM5lKMqU2EsR8dU9sWkWVsgnvtqEd2qZTxajXfZOOpd4Rkauy-Dozz51_rTz2SKzwqvLg0qFk0l6QGZwzBBF6gHaoH3tup7-GqzX8VwaX' +
              'BuVFHQue_ciaMAqEjo');
        },
        url: me.serverEndPoing,
        async: false,
        success: function(result){
          console.log(result)
          me.signature = result
          me.signatureExpire = result.expire
        }
      })
    }
  }
}